<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<link rel="stylesheet" href="./editor.md/css/editormd.min.css" />
	<title>Markdown 在线编辑器</title>
</head>
<body>
<div id="text" style="width: 100%;">
    <div id="editor" style="height: 100%;">
        <!-- Tips: Editor.md can auto append a `<textarea>` tag -->
        <textarea style="display:none;"></textarea>
    </div>
</div>
<button id="get-html-btn">Get HTML</button>

<script src="../js/jquery.min.js"></script>
<script src="./editor.md/editormd.min.js"></script>
<script type="text/javascript">
    // 设置div与窗口高度一致
    window.onload = function () {
        var h = window.innerHeight - 25 ; //获取当前窗口的高度; 
        document.getElementById("text").style.height = h + "px"; //设置div的高度
    }
    // 设置textarea参数
    $(function() {
        var h = window.innerHeight - 25
        var editor = editormd("editor", {
            // width: "100%",
            height: h,
            placeholder: "欢迎使用Markdown在线编辑器！",
            // markdown: "xxxx",     // dynamic set Markdown text
            path : "./editor.md/lib/"  // Autoload modules mode, codemirror, marked... dependents libs path
        });
	$("#get-html-btn").bind('click', function() {
                alert(editor.getHTML());
        });  
    });
</script>
</body>
</html>
